'use strict'; jQuery(document).ready(function($){ $('body').on('click touch', '.woosw-btn', function(e){ var _this=$(this); var product_id=_this.attr('data-id'); var data={ action: 'wishlist_add', product_id: product_id, }; if(_this.hasClass('woosw-added')){ if(woosw_vars.button_action_added==='page'){ window.location.href=woosw_vars.wishlist_url; }else{ if($('#woosw-area .woosw-content-mid'). hasClass('woosw-content-loaded')){ woosw_show(); }else{ woosw_load(); }} }else{ _this.addClass('woosw-adding'); $.post(woosw_vars.ajax_url, data, function(response){ _this.removeClass('woosw-adding'); response=JSON.parse(response); if(( response['status']==1 )&&woosw_vars.button_action!=='message'){ $('#woosw-area').removeClass('woosw-message'); $('#woosw-area .woosw-content-mid'). html(response['value']). removeClass('woosw-content-loaded-message'). addClass('woosw-content-loaded'). perfectScrollbar({theme: 'wpc'}); if(response['notice']!=null){ $('#woosw-area .woosw-notice').html(response['notice']); woosw_notice_show(); setTimeout(function(){ woosw_notice_hide(); }, 3000); }}else{ $('#woosw-area').addClass('woosw-message'); var message='
'; $('#woosw-area .woosw-content-mid'). html(message). removeClass('woosw-content-loaded'). addClass('woosw-content-loaded-message'); } if(response['status']==1){ _this.addClass('woosw-added').html(woosw_vars.button_text_added); } if(response['count']!=null){ woosw_change_count(response['count']); } woosw_show(); }); } e.preventDefault(); }); $('body').on('click touch', '.woosw-content-item--remove span', function(e){ var _this=$(this); var _this_item=_this.closest('.woosw-content-item'); var product_id=_this_item.attr('data-id'); var data={ action: 'wishlist_remove', product_id: product_id, }; _this.addClass('removing'); $.post(woosw_vars.ajax_url, data, function(response){ _this.removeClass('removing'); _this_item.remove(); response=JSON.parse(response); if(response['status']==1){ $('.woosw-btn-' + product_id). removeClass('woosw-added'). html(woosw_vars.button_text); if(response['notice']!=null){ $('#woosw-area .woosw-notice').html(response['notice']); woosw_notice_show(); setTimeout(function(){ woosw_notice_hide(); }, 3000); }}else{ if(response['notice']!=null){ $('#woosw-area .woosw-content-mid'). html('